package fr.umlv.m2.uwp2011.service.matiere.impl;

import java.util.ArrayList;
import java.util.List;

import fr.umlv.m2.uwp2011.persistence.matiere.TroncCommun;
import fr.umlv.m2.uwp2011.persistence.matiere.dao.HibernateTroncCommunDAO;
import fr.umlv.m2.uwp2011.service.matiere.DisplayTroncCommun;
import fr.umlv.m2.uwp2011.service.matiere.ITroncCommunService;

public class TroncCommunServiceImpl implements ITroncCommunService {

	private final HibernateTroncCommunDAO dao = new HibernateTroncCommunDAO();

	@Override
	public List<DisplayTroncCommun> getByUserID(String user_id) {
		List<TroncCommun> listTroncCommun = dao.findByUserID(user_id);
		List<DisplayTroncCommun> listDisplayTroncCommun = new ArrayList<DisplayTroncCommun>(listTroncCommun.size());
		
		for(TroncCommun troncCommun : listTroncCommun) {
			DisplayTroncCommun dc = new DisplayTroncCommun();
			dc.setTroncCommun(troncCommun);
			listDisplayTroncCommun.add(dc);
		}
		
		return listDisplayTroncCommun;
	}
	
}
